import store from '@/store/index.js'
import {
	pub,
	publike
} from '@/common/event.js'
export default {
	handle: function(message) {
		if (message.type != "ping") {
			console.log(`消息处理函数:::`, message)
		}
		if (message.type.indexOf(`MT_`) == 0) {
			publike("socket_" + message.type, message.data)
			pub("socket_"+message.type, message.data)
			return
		}
		switch (message.type) {
			case "register_res":
				store.commit({
					type: "websocket/setConnectSuccess",
					payload: true
				})
				pub("registerSucess", {})
				break;
			case "fmessage":
				pub("socket_fmessage", message.data)
				break;
			case "friendApply":
				pub("socket_friendApply", message.data)
				break;
			case "passapply":
				pub("socket_passapply", message.data)
				break;
			case "fmessage_error":
				pub("socket_fmessage_error", message.data)
				break;
			case "gmessage":
				pub("socket_gmessage", message.data)
				break;
			case "changeGroupInfo":
				pub("socket_changeGroupInfo", message.data)
				break;
			case "makeNewGroup":
				pub("socket_makeNewGroup", message.data)
				break;
			case "addUserToGroup":
				pub("socket_addUserToGroup", message.data)
				break;
			case "deleteGroup":
				pub("socket_deleteGroup", message.data)
				break;
			case "exitGroup":
				pub("socket_exitGroup", message.data)
				break;
			case "videocallinvite":
				pub("socket_videocallinvite", message.data)
				break;
			case "iambusy":
				pub("socket_iambusy", message.data)
				break;
			case "cancelvideocall":
				pub("socket_cancelvideocall", message.data)
				break;
			case "refusevideocall":
				pub("socket_refusevideocall", message.data)
				break;
			case "agreevideocall":
				pub("socket_agreevideocall", message.data)
				break;
			case "hangoffvideocall":
				pub("socket_hangoffvideocall", message.data)
				break;
			case "createRoom":
				pub("socket_createRoom", message.data)
				break;

			default:
				break;
		}
	}
}